//1.输入一个数字，判断这个数字是否是5或7的倍数
let readline=require( "readline-sync");
console.log("请输入数字：");
let num=readline.question("");
if(num %5==0 || num%7==0){
    console.log("是倍数")
}else {
    console.log("不是倍数");
}
//2.输入年份，判断是否是闰年
let readline=require( "readline-sync");
console.log("请输入年份:");
let year=readline.question("");
if(year%400==0)
 console.log("此年是闰年");
else
{
    if(year%4==0&&year%100!=0)
        console.log("此年是闰年");
    else
        console.log("此年不是闰年");
}
//3.计算器
//4.运输公司计算运费，路程遥远，运费的折扣越高
// //路程s< 250km 0%
// //250km <= s <=500km 2%

if (s >= 3000 ) c =12;
else c = s / 250;
switch (c)
{
    case 0 :d = 0; break;
    case 1 :d = 2; break;
    case 2 :
    case 3 :d = 5; break;
    case 4 :
    case 5 :
    case 6 :
    case 7 :d = 8; break;
    case 8 :
    case 9 :
    case 10:
    case 11:d = 10; break;
    case 12:d = 15; break;
}
console.log("所需运费：");
//5.
if(x/100000)
{
    console.log("超过范围！\n");

}
i=0;
do
{
    c[i++]=x%10;
}while(x /= 10);
console.log("%d位数\n",i);
while(i >0)
    console.log("%d ",c[--i]);
//
console.log("输入你的成绩");
switch (score) {
    case 1: score>100 & score<0 ;console.log("请输入正确的分数")
    case 2:

}
//
let reactChild=readline.getRawInput()
let year=readline.question("");
let data=readline.question("");
console.log("请输入你的日期");
if(year%400==0)
    console.log("此年是闰年");
else
{
    if(year%4==0&&year%100!=0)
        console.log("此年是闰年");
    else
        console.log("此年不是闰年");
}
//
let i=100;
for(i;i<=200;i++){
    if(i%3==0&&i%7==0){
        console.log(i);
    }
}
//1.输入100-999之间的水仙花数
let i=readline.question("");
console.log("请输入数字");
for (i = 100; i < 1000; i++)
{
    a = i / 100;//百位
    b = i % 100 / 10;//十位
    c = i % 10;//个位

    if (i == a*a*a + b*b*b + c*c*c)//判断i是否为水仙花数
        console.log(i);
}
//2、随机输入一个数，判断该数是否为素数

    console.log("请输入一个数：");
    let i=readline.question("");

    for(i=2;i<n;i++)
    {
        if(n%i==0)
        {
            a++;
        }
        if(i==a)
            console.log("%d 是素数\n",n);
    }
    console.log("%d 不是素数\n",n);

//3.判断是否是回文数
let isPalindrome = function(x) {
    let str = x + ''
    let newStr = ''
    for(let len = str.length, i = len - 1; i >= 0 ; i--) {
        newStr += str[i]
    }
return newStr === str
}
//4.

let a = Number(prompt("输入一个数(0~9)"));
let b = 0;
let sum = 0;
let n = Number(prompt("输入项数"));
let i = 0;
while (i < n) {
    b = b*10 + a;
    sum = sum + b;
    i++;
}
console.log(sum);

//5.
for (var i=1;i<=5;i++) {
    for (var j=1;j<=i;j++) {
        document.write("*");
    }
    document.write("<br/>");
}

//8-12
//1.ATM机
//2.初始3行4列的数组转化为4行3列的数组
//3.杨辉三角
let readline = require('readline-sync');
console.log('请输入杨辉三角的行数:');
let line = readline.question('');
let arr = [],nbsp = '';
// 创建二维数组，每行作为1个数组保存
for (let i = 0; i < line; i++) {
    arr[i] = new Array(i + 1);
}
for (let i = 0; i < line; i++) {
    // 计算每个值存进数组中
    for (let j = 0; j <= i; j++) {
        if (j == 0 || j == i) {
            arr[i][j] = 1;
        } else {
            arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];
        }
    }
}
for (let i = 0; i < line; i++) {
    // 添加空格
    nbsp = '';
    for (let j = 0; j < line - i - 1; j++) {
        nbsp += ' ';
    }
    console.log(nbsp+arr[i])
}